package br.com.mobile.listadapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import br.com.pfc.mobile.R;
import br.com.pfc.mobile.transferobject.ClienteTO;

public class ClienteListAdapter extends BaseAdapter{
	private Context context;
	private List<ClienteTO> lista; 	
	
	
	public ClienteListAdapter(Context context, List<ClienteTO> lista) {
		super();
		this.context = context;
		this.lista = lista;
	}

	public int getCount() {
		
		return lista.size();
	}

	public Object getItem(int posicao) {
		
		return lista.get(posicao);
	}

	public long getItemId(int posicao) {
			return posicao;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		ClienteTO cliente = lista.get(position);
		LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View view = inflater.inflate(R.layout.cliente_list, null);
		
		TextView nome = (TextView) view.findViewById(R.id.cliente_nome);
		TextView documento = (TextView) view.findViewById(R.id.cliente_documento);
		
		nome.setText(cliente.getNome());
		documento.setText(cliente.getDocumento());
		return view;
	}

}
